/*
 * Config.h
 *
 *  Created on: Oct 28, 2019
 *      Author: nxa07657
 */

#ifndef CONFIG_H_
#define CONFIG_H_

#include "Cpu.h"

#define DownLoadID  0x64   /*the CAN message ID for bootloader download*/
#define UpLoadID    0xC8   /*the CAN message ID for bootloader upload*/

#define TX_MB  0  /*use MB0 for CAN message transmit*/
#define RX_MB  1  /*use MB1 for CAN message receive*/

/* define the APP PFLASH start address */
#define APP_PFLASH_START_ADDR 0x8000

/* get the content(reset/start function address) of the user application project from its reset_handler address*/
#define APP_StartAddr (*(uint32_t*)(APP_PFLASH_START_ADDR + 4))

/*the void type function pointer definition for bootloader to user application jump*/
typedef void (* Jump_Func)(void);

#define _S32K144_EVB_   /* select to use S32K144 EVB */

#ifdef _S32K144_EVB_
/*********************************************************************
* the RGB LED PORT, GPIO and PIN definition according S32K144-EVB
*********************************************************************/
#define LED_PORT    PORTD
#define LED_GPIO    PTD
#define BLUE_PIN    (1<<0)
#define RED_PIN     (1<<15)
#define GREEN_PIN   (1<<16)

typedef enum{
BLUE = 0,
RED = 15,
GREEN = 16
} RGB_LED_Type;

#define RGB_BLUE_LED_Toggle()   PINS_DRV_TogglePins(LED_GPIO,BLUE_PIN)
#define RGB_RED_LED_Toggle()    PINS_DRV_TogglePins(LED_GPIO,RED_PIN)
#define RGB_GREEN_LED_Toggle()  PINS_DRV_TogglePins(LED_GPIO,GREEN_PIN)

#define RGB_BLUE_LED_On()   PINS_DRV_ClearPins(LED_GPIO,BLUE_PIN)
#define RGB_RED_LED_On()    PINS_DRV_ClearPins(LED_GPIO,RED_PIN)
#define RGB_GREEN_LED_On()  PINS_DRV_ClearPins(LED_GPIO,GREEN_PIN)

#define RGB_BLUE_LED_Off()   PINS_DRV_SetPins(LED_GPIO,BLUE_PIN)
#define RGB_RED_LED_Off()    PINS_DRV_SetPins(LED_GPIO,RED_PIN)
#define RGB_GREEN_LED_Off()  PINS_DRV_SetPins(LED_GPIO,GREEN_PIN)

#define RGB_LED_Ctrl(led, ctrl)  PINS_DRV_WritePin(LED_GPIO,led,ctrl)

/*********************************************************************
* the user buttons(SW) PORT, GPIO and PIN definition according S32K144-EVB
*********************************************************************/
#define USER_SW_PORT    PORTC
#define USER_SW_GPIO    PTC

#define SW2_PIN    		12
#define SW3_PIN    		13

#define SW2_PIN_MASK    		(1<<SW2_PIN)
#define SW3_PIN_MASK    		(1<<SW3_PIN)

#define USER_SW_GPIO_IRQn   PORTC_IRQn

#endif  /*end of _S32K144_EVB_*/

extern flash_ssd_config_t pSSDConfig;

#endif /* CONFIG_H_ */
